package com.sxit.myproscenium.system.controller;

import com.sxit.myproscenium.common.response.R;
import com.sxit.myproscenium.system.entity.Goods;
import com.sxit.myproscenium.system.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.server.PathParam;
import java.util.List;

/**
 * 前端控制器
 *
 * @author wcn
 * @since 2022-04-10
 */
@RestController
@RequestMapping("/system/goods")
public class GoodsController {

  @Autowired private IGoodsService goodsService;

  @GetMapping("/getGoodsList")
  public R getGoodsList() {
    List<Goods> list = goodsService.getGoodsList();
    return R.ok().put("data", list);
  }

  @GetMapping("/getDetailInfo")
  public R getDetailInfo(@PathParam("goodsId") String goodsId) {

    Goods byId = goodsService.getById(goodsId);
    return R.ok().put("data", byId);
  }
}
